package com.netjava.loadCofig;

import java.io.File;
import java.net.URL;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.web.context.ContextLoaderServlet;

public class LoadSpringConfig {
	/**
	 * 加载Spring的配置文件
	 * @return
	 */
	public ApplicationContext loadSpring(){
		URL url=ContextLoaderServlet.class.getResource("/");
		File file=new File(url.getPath()).getParentFile();
		String contextPath="WebRoot/WEB-INF/applicationContext.xml";
		ApplicationContext context=new FileSystemXmlApplicationContext(contextPath);
		return context;
	}
}
